<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="false" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<jsp:include page="/WEB-INF/views/common/header.jsp" />

<link rel="stylesheet" href="<c:out value="${pageContext.request.contextPath}"/>/resources/common/bootstrap/css/bootstrap-datepicker.min.css">

<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}"/>/resources/common/bootstrap/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}"/>/resources/js/customer_popup.js"></script>
<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}"/>/resources/js/delivery_dept_popup.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		$('#relase_date').datepicker({
			format: "yyyy-mm-dd",
			autoclose: true,
			todayHighlight: true
		})
		
		$('#dept_code').val("10101");
		$('#dept_name').val("총괄기술센터");
	});
	
	function retrieve() {
		var deptCode 			= $('#dept_code').val();
		var repairVendorCode	= $('#repair_vendor_code').val();
		var serialNo 			= $('#serial_no').val();
		
		if ( deptCode == null || deptCode.trim().length == 0 ) {
			alert("수리요청 부서는 필수입니다.");
			return;
		}
		
		if ( repairVendorCode == null || repairVendorCode.trim().length == 0 ) {
			alert("수리처는 필수입니다.");
			return;
		}
		
		$.ajax({
			url: contextPath + "/repair_order_delivery",
			data: {repairVendor:repairVendorCode, mgtDept:deptCode, serialNo:serialNo},
			type: 'GET',
			dataType: 'json'
		}).done(function(data) {
			$('#result_table').bootstrapTable('load', data);
		});
	}
</script>

</head>
<body>
	<jsp:include page="/WEB-INF/views/main/menu.jsp" />

	<div class="container">
		<div class="page-header">
			<h3>수리 요청 출고</h3>
		</div>
		<form class="form-inline">
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="repair_order_dept" style="width: 100px;">수리요청 부서</label> 
						<input type="text" class="form-control" id="dept_code" placeholder="부서 코드" disabled>
						<div class="input-group">
							<input type="text" class="form-control" id="dept_name" placeholder="부서명" disabled> 
							<span class="input-group-btn"> 
								<input type="button" class="btn btn-primary btn-sm" id="repair_order_dept_btn" value="선택" />
							</span>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="repair_vendor" style="width: 100px">수리처</label> 
						<input type="text" class="form-control" id="repair_vendor_code" placeholder="수리처 코드" disabled>
						<div class="input-group">
							<input type="text" class="form-control" id="repair_vendor_name" placeholder="수리처 명" disabled> 
							<span class="input-group-btn"> 
								<input type="button" class="btn btn-primary btn-sm" id="repair_vendor_btn" value="선택" />
							</span>
						</div>
					</div>
				</div>
			</div>
			<p/>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="release_day" style="width: 100px">출고일</label>
						<div class="input-group date" id="relase_date">
  							<input type="text" class="form-control" size="52" readonly="readonly">
  								<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="request_code" style="width: 100px">출고번호</label> 
						<input type="text" class="form-control" id="request_code" size="59">
					</div>
				</div>
			</div>
			<p/>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="serial_no_scanning" style="width: 100px">Serial No</label> 
						<input type="text" class="form-control" id="serial_no_scanning" size="59">
					</div>
				</div>
			</div>
			<p/>
			<div class="row">
				<div class="col-sm-push-10 col-sm-2">
					<input type="button" class="btn btn-primary btn-sm btn-block" id="retrieve_btn" value="조회" onclick="retrieve()">
				</div>
			</div>
		</form>
		<p />
		<!--
			<div class="fixed-table-container">
			<div style="overflow-x:auto">
			<div class="table-responsive">
			-->
		<!-- 
			<table data-toggle="table" data-url="<c:out value="${pageContext.request.contextPath}"/>/resources/test_data/data.json" data-height="400" data-side-pagination="server" data-pagination="true" data-page-list="[5, 10, 20, 50, 100]" data-search="false">
			 -->
		<table id="result_table" data-toggle="table"
			<%-- data-url="<c:out value="${pageContext.request.contextPath}"/>/resources/test_data/data.json" --%>
			data-height="400" data-pagination="true" data-search="false" style="width:2400px;">
			<thead>
				<tr>
					<th data-field="state" data-checkbox="true"></th>
					<th data-field="rowNum" data-align="center">No</th>
					<th data-field="serialNo" data-align="center">Serial No.</th>
					<th data-field="itemSegment" data-align="center">품목코드</th>
					<th data-field="itemDescription" data-align="center">품명</th>
					<th data-field="lastRepairVendor" data-align="center">이전 수리처</th>
					<th data-field="accountName" data-align="center">고객명</th>
					<th data-field="lastRepairCompleteDate" data-align="center">최종수리일</th>
					<th data-field="vendorWarrantyName" data-align="center">Vendor Warr</th>
					<th data-field="vendorDueDate" data-align="center">납기일</th>
					<th data-field="mfgDate" data-align="center">Mfg Date</th>
					<th data-field="custBillable" data-align="center">고객청구 여부</th>
					<th data-field="itemGroup" data-align="center">기종코드</th>
					<th data-field="revision" data-align="center">REVISION</th>
					<th data-field="attribute1" data-align="center">수리 유형</th>
					<th data-field="vendorReworkSeq" data-align="center">재수리 차수</th>
					<th data-field="roLineId" data-align="center">RO Line ID</th>
					<th data-field="roHeaderId" data-align="center">RO Header ID</th>
				</tr>
			</thead>
		</table>
		<p />
		<form class="form-inline">
		<div class="row">
			<div class="col-sm-5">
				<div class="form-group form-group-sm">
					<label class="control-label" for="release_target_count" style="width: 100px">출고대상 수량</label> 
					<input type="text" class="form-control" id="request_code" size="50" value="0"  style="text-align:right;">
				</div>
			</div>
			<div class="col-sm-5">
				<div class="form-group form-group-sm">
					<label class="control-label" for="release_count" style="width: 100px">출고 수량</label> 
					<input type="text" class="form-control" id="request_code" size="50" value="0"  style="text-align:right;">
				</div>
			</div>
			<div class="col-sm-2">
				<a href=""><input type="button" class="btn btn-primary btn-sm btn-block" id="release_btn" value="출고"></a>
			</div>
		</div>
		</form>
	</div>
	<div class="modal fade" role="dialog" id="modal_div">
		<div class="modal-dialog">
			<div class="modal-content"></div>
		</div>
	</div>
</body>
</html>